/*
 * Project : Linuxbox
 * File    : UserManDel.java
 * Version : 1.0
 * Author  : Kevin Zhang
 *
 * Copyright (c) 2000-2001 by Linuxbox, Inc.
 * All rights reserved.
 */
package linuxbox.download.servlet;

import javax.servlet.http.*;

import java.io.*;

import linuxbox.BoxStatic;
import linuxbox.common.*;
import linuxbox.download.logic.*;

public class DlFileDelAction extends Action {
	protected static final String DL_CAT_ID_PARAM = "DL_FILE_ID";         

	protected static String successJSP = null;
	
    public void doAction(HttpSession aSession, BoxSession aBoxSession, 
    HttpServletRequest req, HttpServletResponse res) throws Exception {
		int CatID = Integer.parseInt(req.getParameter(DL_CAT_ID_PARAM));
	
		DownLoadManager dlm = DownLoadManager.getInstance();
		DownLoadObject dlo = dlm.getDownLoad(CatID);
		String FileName = dlo.getFileName();
		
		File file = new File(BoxStatic.HOME_DIR 
			+ BoxStatic.DOWNLOAD_FILE_DIR + FileName);
			
		if (file.exists())
			file.delete();
			
		dlm.removeDownLoad(CatID);

		redirectFile(successJSP, req, res);
	}

	public void setSuccessJSP(String str) {
		successJSP = str;
	}
}
